<template>
  <div class="body">
    <div class="container">
      <div class="background"></div>

      <!-- 导航栏 -->
      <div class="nav-Bot">
        <div class="title">
          <span>发现 AI Bot</span>
        </div>
        <div class="search">
          <Search></Search>
        </div>
        <div class="buttons">
          <button class="collect">查看 BOT 收藏</button>
          <button class="create">创建 BOT</button>
        </div>
      </div>
      <!-- 工具栏 -->
      <JuejinTools />
      <!-- 服务栏 -->

      <div class="tabs-header">
        <RouterLink
          :to="{ path: item.url }"
          v-for="item in tabsTitle"
          :key="item.title"
        >
          <div
            class="tabs-title"
            :class="{ active: item.isActive }"
            @click="toggleActive(item)"
          >
            {{ item.title }}
          </div>
        </RouterLink>
      </div>
      <!-- 用户互动 -->
      <RouterView :key="$route.fullPath"></RouterView>
    </div>
  </div>
</template>

<script setup lang="ts">
import Search from '@/components/juejinSearch.vue'
import JuejinTools from './juejinTools.vue'
import { RouterLink, RouterView } from 'vue-router'
import { ref } from 'vue'

const tabsTitle = ref([
  {
    title: '推荐',
    url: '/tj',
    isActive: true,
  },
  {
    title: '效率工具',
    url: '/xlgj',
    isActive: false,
  },
  {
    title: '商业服务',
    url: '/syfw',
    isActive: false,
  },
  {
    title: '文本创作',
    url: '/wbcz',
    isActive: false,
  },
  {
    title: '学习教育',
    url: '/xxjy',
    isActive: false,
  },
  {
    title: '代码助手',
    url: '/dmzs',
    isActive: false,
  },
  {
    title: '生活方式',
    url: '/shfs',
    isActive: false,
  },
  {
    title: '游戏',
    url: '/yx',
    isActive: false,
  },
  {
    title: '图像与音视频角色',
    url: '/txyyspjs',
    isActive: false,
  },
])

const toggleActive = (item: { isActive: boolean }) => {
  for (let i = 0; i < tabsTitle.value.length; i++) {
    tabsTitle.value[i].isActive = false
  }
  item.isActive = !item.isActive
}
</script>

<style lang="scss" scoped>
/* body部分 */
.body {
  width: 100%;
  height: 100%;
  background-color: #e2ecf5;

  .container {
    display: flex;
    flex-direction: column;
    align-items: start;
    justify-content: center;
    width: 1200px;
    min-height: 100vp;
    margin: 0 auto;

    .background {
      position: fixed;
      z-index: -1;
      top: 0;
      left: 0;
      width: 100vw;
      height: 1200px;
      opacity: 0.5;
      background: linear-gradient(rgba(30, 161, 255, 0.2), #f2f3f5);
    }
    // 导航条
    .nav-Bot {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      margin: 40px 0 30px;
      width: 100%;

      .title {
        span {
          flex-shrink: 0;
          color: #1e80ff;
          font-size: 34px;
          font-style: normal;
          font-weight: 800;
          line-height: 28px;
        }
      }

      .buttons {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        width: 225px;
        height: 36px;

        .collect {
          width: 125px;
          font-size: 13px;
          color: #1e80ff;
          border: 1px solid rgba(30, 128, 255, 0.3);
          border-radius: 4px;
          margin-right: 8px;
          padding: 3px 16px;
          background-color: #fff;
        }

        .create {
          width: 82px;
          font-size: 11px;
          color: #fff;
          border-radius: 2px;
          border: none;
          outline: none;
          background-color: #007fff;
          transition:
            background-color 0.3s,
            color 0.3s;
          cursor: pointer;
        }
      }
    }

    // 工具栏

    // 服务栏
    .tabs-header {
      box-sizing: border-box;

      padding: 12px 0;
      display: flex;
      justify-content: start;
      // margin-top: 40px;

      .tabs-title {
        padding: 12px 20px;
        color: #252933;
        margin-right: 8px;
        background-color: #fff;
        border-radius: 4px;
        box-shadow:
          0 15px 35px -2px rgba(0, 0, 0, 0.05),
          0 5px 15px 0 rgba(0, 0, 0, 0.05);
        white-space: nowrap;
        font-size: 16px;
        line-height: 20px;
        cursor: pointer;
      }
      .active {
        color: #1e80ff;
      }
    }
    // 用户互动
  }
}
</style>
